package br.com.cefetrn.apoena.dominio.home;

// Generated 01/01/2008 17:35:51 by Hibernate Tools 3.2.0.b11

import br.com.cefetrn.apoena.dominio.entity.Noticia;

/**
 * Home object for domain model class Noticia.
 * 
 * @see br.com.cefetrn.apoena.dominio.entity.Noticia
 * @author Gilmar P.S.L.
 */
public class Home4Noticia extends AxHomeGeneric<Noticia, Integer> {

	Home4Pessoa pessoaHome = new Home4Pessoa();
	Home4NoticiaFotos notfotHome = new Home4NoticiaFotos();

	@Override
	public Noticia persist(Noticia instance) {
		// TODO Auto-generated method stub
		Noticia noticia = null;

		pessoaHome.setSession(getSession());
		if (instance != null)
			noticia = super.persist(instance);
		else
			throw new RuntimeException(
					"Pessoa nao cadastrada! Cadastro de noticia nao autorizado");

		return noticia;
	}

	@Override
	public Noticia delete(Noticia persistentInstance) {
		// TODO Auto-generated method stub

		notfotHome.setSession(getSession());
		notfotHome.delete(persistentInstance.getNoticiaFotoses());

		return super.delete(persistentInstance);
	}

}
